$executingScriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
. "$executingScriptDir\PsUtils.ps1"

if((Test-Path $pathDistribution) -eq $false) {
	mkdir $pathDistribution
}

Get-ChildItem $pathSource -Recurse -Filter "Compiled" | ForEach-Object {
	$compiledDir = $_.FullName
	$projectName = (Get-Item $compiledDir).Parent.Name
	
	copy License.txt (Join-Path $compiledDir "RenewalProjects.License.txt")
	
	Get-ChildItem $compiledDir | ForEach-Object {
		$filename = $_.Name
		$ext = [System.IO.Path]::GetExtension($filename)
		$assemblyName = $filename.Replace($ext, "")
		$assemblyPath = Join-Path $pathThirdParty $assemblyName
		$licensePath = "$assemblyPath.License.txt"
		if((Test-Path $licensePath) -eq $true) {
			copy $licensePath $compiledDir
		}
	}
	
	$zipPath = Join-Path $pathDistribution "$projectName.zip"
	Get-ChildItem $compiledDir | Zip $zipPath $compiledDir
}